xend: Restore scheduling parameters
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 16 Jul 2009 09:32:55 +0000 (10:32 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 16 Jul 2009 09:32:55 +0000 (10:32 +0100)
Scheduling parameters are reset to default values when I restore
or migrate a domain.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
tools/python/xen/xend/XendConfig.py
tools/python/xen/xend/XendDomainInfo.py

index 0871d9ac8ab2ab26f80aa5d6a5d7a681e08d669e..2cca3d5131b33e71594999d7df8629a90187a629 100644 (file)
@@ -1055,7 +1055,10 @@ class XendConfig(dict):
         if domain.getDomid() is not None:
             sxpr.append(['domid', domain.getDomid()])
 
-        if not legacy_only:
+        if legacy_only:
+            sxpr.append(['cpu_weight', int(self['vcpus_params'].get('weight', 256))])
+            sxpr.append(['cpu_cap', int(self['vcpus_params'].get('cap', 0))])
+        else:
             for name, typ in XENAPI_CFG_TYPES.items():
                 if name in self and self[name] not in (None, []):
                     if typ == dict:
index ff38009d08a3ce5f9b4ee7bff7659644449eeb2c..3f2683d6cb3d4c241938916e8769c53f9ae9f0aa 100644 (file)
@@ -465,17 +465,11 @@ class XendDomainInfo:
                 XendTask.log_progress(91, 100, self.refreshShutdown)
 
                 xendomains = XendDomain.instance()
-                xennode = XendNode.instance()
 
                 # save running configuration if XendDomains believe domain is
                 # persistent
                 if is_managed:
                     xendomains.managed_config_save(self)
-
-                if xennode.xenschedinfo() == 'credit':
-                    xendomains.domain_sched_credit_set(self.getDomid(),
-                                                       self.getWeight(),
-                                                       self.getCap())
             except:
                 log.exception('VM start failed')
                 self.destroy()
@@ -497,6 +491,7 @@ class XendDomainInfo:
                     # we just ignore it so that the domain can still be restored
                     log.warn("Cannot restore CPU affinity")
 
+                self._setSchedParams()
                 self._storeVmDetails()
                 self._createChannels()
                 self._createDevices()
@@ -2555,6 +2550,12 @@ class XendDomainInfo:
                 for v in range(0, self.info['VCPUs_max']):
                     xc.vcpu_setaffinity(self.domid, v, cpumask)
 
+    def _setSchedParams(self):
+        if XendNode.instance().xenschedinfo() == 'credit':
+            from xen.xend import XendDomain
+            XendDomain.instance().domain_sched_credit_set(self.getDomid(),
+                                                          self.getWeight(),
+                                                          self.getCap())
 
     def _initDomain(self):
         log.debug('XendDomainInfo.initDomain: %s %s',
@@ -2571,6 +2572,9 @@ class XendDomainInfo:
             # distribution for NUMA systems.
             self._setCPUAffinity()
 
+            # Set scheduling parameters.
+            self._setSchedParams()
+
             # Use architecture- and image-specific calculations to determine
             # the various headrooms necessary, given the raw configured
             # values. maxmem, memory, and shadow are all in KiB.